import request from '/src/axios.js';
import {baseUrl} from "../../config/env";

export const gatewayApi = {
  getList: (current, size, params) => request({
    url: baseUrl + '/api-gateway/route/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  }),
  getDetail: (id) => request({
    url: baseUrl + '/api-gateway/route/detail',
    method: 'get',
    params: {
      routeId: id
    }
  }),
  remove: (ids) => request({
    url: baseUrl + '/api-gateway/route/' + ids,
    method: 'delete',
  }),
  add: (row) => request({
    url: baseUrl + '/api-gateway/route/submit',
    method: 'post',
    data: row
  }),
  update: (row) => request({
    url: baseUrl + '/api-gateway/route/update',
    method: 'post',
    data: {
      id: row.id,
      routeId: row.routeId,
      predicates: JSON.parse(row.predicates),
      filters: JSON.parse(row.filters),
      uri: row.uri,
      sort: row.sort,
      description: row.description
    }
  }),
  sync: () => request({
    url: baseUrl + '/api-gateway/route/sync',
    method: 'get',
    // data: row
  }),
  updateFlag: (row) => {
    return request({
      url: baseUrl + '/api-gateway/route/updateFlag',
      method: 'get',
      data: row
    })
  }
}


